<template>
  <transition name="slide-fade" @after-leave="transitionComplete">
    <div
      v-show="isHidden"
      role="alert"
      class="el-notification right"
      :style="{backgroundColor:Color[type],fontSize:'30px'}"
      style="z-index: 2004;"
    >
      <div class="el-notification__group">
        <h2 class="el-notification__title">{{title}}</h2>
        <div class="el-notification__content">
          <p>{{message}}</p>
        </div>
        <div class="el-notification__closeBtn el-icon-close" @click="closeNotice">×</div>
      </div>
    </div>
  </transition>
</template>

<script>
import {Ranking} from "./index.js"

export default {
  name: "hmNotice",
  data() {
    return {
      title: "我是默认标题",
      message: "我是默认信息",
      duration: 4000,
      isHidden: false,
      offsetTop: 0,
      isRemove: false,
      Color: {
        success: "#f0f9eb",
        error: "#fef0f0",
        warn: "#fdf6ec",
        message: "#edf2fc",
      },
      type: "",
    };
  },
  mounted() {
    console.log(this.Color[this.type]);
    setTimeout(() => {
      this.isHidden = false;
    }, this.duration);

    this.isHidden = true;
  },
  methods: {
    closeNotice() {
      this.isHidden = false;
    },
    transitionComplete() {
      this.$el.remove();
      this.isRemove = true;
      Ranking()
    },
  },
};
</script>


<style lang="scss">
.slide-fade-enter-active {
  transition: all 0.5s ease !important;
}
.slide-fade-leave-active {
  transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1) !important;
}
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ {
  transform: translateX(100px);
  opacity: 0;
}

.el-notification {
  display: flex;
  width: 330px;
  padding: 14px 26px 14px 13px;
  border-radius: 8px;
  box-sizing: border-box;
  border: 1px solid #ebeef5;
  position: fixed;
  background-color: #fff;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  overflow: hidden;
  //   控制重新排位的动画
  transition: all 0.5s;
  &.right {
    right: 16px;
  }

  .el-notification__group {
    margin-left: 13px;
    margin-right: 8px;

    .el-notification__title {
      font-weight: 700;
      font-size: 16px;
      color: #303133;
      margin: 0;
    }

    .el-notification__content {
      font-size: 14px;
      line-height: 21px;
      margin: 6px 0 0;
      color: #606266;
      text-align: justify;
    }

    .el-notification__closeBtn {
      position: absolute;
      top: 18px;
      right: 15px;
      cursor: pointer;
      color: #909399;
      font-size: 16px;
    }
  }
}
</style>